package day1;

import java.util.HashMap;
import java.util.Scanner;

class Solution {

}
public class Test {
    public static int missingNumber(int[] nums) {
        HashMap<Integer,Integer> hashMap = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            hashMap.put(nums[i],1);
        }
        for (int i = 0; i < nums.length; i++) {
            if(hashMap.getOrDefault(i,0) == 0) {
                return i;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        int[] array = {0,1,3};
        int a = missingNumber(array);
        System.out.println(a);
    }

    public static String replaceSpace(String s) {
        int count = 0;
        for (int i = 0; i < s.length(); i++) {
            if(s.charAt(i) == ' '){
                count++;
            }
        }
        char[] a = new char[s.length()+count*2];
        int m = s.length()-1;
        int n = a.length-1;
        while (m >= 0 && n >= 0) {
            if(s.charAt(m) == ' ') {
                a[n] = '0';
                n--;
                a[n] = '2';
                n--;
                a[n] = '%';
                n--;
                m--;
            } else {
                a[n] = s.charAt(m);
                n--;
                m--;
            }
        }
        return String.valueOf(a);

    }

    public static void main2(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String cur = "";
        String ret = "";
        int i = 0;
        for (; i < s.length(); i++) {
            char ch = s.charAt(i);
            if(ch >= '0' && ch <= '9') {
                cur = cur+ch;
            }else {
                if(cur.length() > ret.length()) {
                    ret = cur;
                    cur = "";
                }else  {
                    cur = "";
                }
            }
        }
        if(i == s.length() && cur.length() > ret.length()) {
            ret = cur;
        }
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        replaceSpace("i like");
    }

}
